package com.gnerv.sylvanas.framework.plugin.init.sql.config;

public class SqlInitDatabaseConfig {

//
//    @Bean
//    @ConditionalOnBean(value = {DataSource.class, BaseDatabaseInitService.class})
//    public DataSourceScriptDatabaseInitializer databaseInitializer(List<BaseDatabaseInitService> databaseInitServiceList, DataSource dataSource) {
//        DatabaseInitializationSettings settings = new DatabaseInitializationSettings();
//        settings.setEncoding(StandardCharsets.UTF_8);
//        for (BaseDatabaseInitService databaseInitService : databaseInitServiceList) {
//            List<String> schemaLocationList = databaseInitService.schemaLocationList();
//            if (!CollectionUtils.isEmpty(schemaLocationList)) {
//                List<String> schemaLocationAllList = settings.getSchemaLocations();
//                if (CollectionUtils.isEmpty(schemaLocationAllList)) {
//                    schemaLocationAllList = new ArrayList<>();
//                }
//                schemaLocationAllList.addAll(databaseInitService.schemaLocationList());
//                settings.setSchemaLocations(schemaLocationAllList);
//            }
//            List<String> dataLocationList = databaseInitService.dataLocationList();
//            if (!CollectionUtils.isEmpty(dataLocationList)) {
//                List<String> dataLocationAllList = settings.getDataLocations();
//                if (CollectionUtils.isEmpty(dataLocationAllList)) {
//                    dataLocationAllList = new ArrayList<>();
//                }
//                dataLocationAllList.addAll(databaseInitService.dataLocationList());
//                settings.setDataLocations(dataLocationAllList);
//            }
//        }
//        settings.setContinueOnError(true);
//        return new DataSourceScriptDatabaseInitializer(dataSource, settings);
//    }

}